﻿@using System.Linq
@{
    var CurentUser = Session["CurentUser"] as HanGu.Entity.CurrentUserDTO;
    var menuRoles = new List<HanGu.Entity.VRolePurview>();
    if (CurentUser != null && CurentUser.Roles != null)
    {
        menuRoles = CurentUser.Roles;
    }
    //Func<List<HanGu.Entity.VRolePurview>, int, HtmlString> SubMenu1 = (roles, deep) =>
    //{
    //    string header = "<ul {1}>{0}</ul>";
    //    string itemstr = "<li><a href='{0}' target='{1}' rel='{2}' fresh='{3}' External='{4}'>{5}</a></li>";
    //    string headerclass = string.Empty;
    //    headerclass = deep > 1 ? string.Empty : "class=\"tree treeFolder\"";
    //    string result = string.Empty;

    //    foreach (var m in roles)
    //    {
    //        var navTabid = m.Url.Replace('/', ' ').Trim();
    //        var rels = navTabid.Split(' ').ToList();
    //        int index = rels.Count >= 3 ? 2 : 1;
    //        string rel = string.Empty;
    //        for (int i = 0; i < index; i++)
    //        { rel += rels[i]; }
    //        result += string.Format(itemstr,
    //            m.Url,
    //            m.Target,
    //            rel,
    //            !string.IsNullOrEmpty(m.Fresh) ? m.Fresh.ToLower() : "",
    //            !string.IsNullOrEmpty(m.External) ? m.External.ToLower() : "",
    //            m.ModuleName);
    //    }
    //    if (!string.IsNullOrEmpty(result))
    //    {
    //        result = string.Format(header, result, headerclass);
    //    }

    //    return new HtmlString(result);
    //};
        
}

<div class="accordion" fillspace="sidebar">
    @foreach (var item in menuRoles.Where(c => string.IsNullOrEmpty(c.Parent) && (c.Types.HasValue && c.Types == 0 || !c.Types.HasValue)).OrderBy(c => c.Order))
    { 
        <div class="accordionHeader">
            <h2>
                <span>Folder</span>@item.ModuleName</h2>
        </div>
        <div class="accordionContent">
            @HanGu.CRM.MyHtmlHelper.GenerateLeftMenu(menuRoles.Where(c => c.Parent == item.ID && c.Types == 0).ToList(), menuRoles, 1)
            
        </div>
    }
</div>
